package com.gcstorage.tvdev.net;

import android.telephony.mbms.DownloadProgressListener;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * created by Sanpark on Date: 2020/5/29 10:11
 */
public class DownloadInterceptor implements Interceptor {
    private DownloadProgressListener mListener;

    public DownloadInterceptor() {
    }

    public DownloadInterceptor(DownloadProgressListener listener) {
        this.mListener = listener;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());
        return response.newBuilder()
                .body(new DownloadResponseBody(response.body(), mListener))
                .build();
    }
}
